﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2021-2025 LiLong                                              **
**  This file is part of CommonUnits.                                           **
**                                                                              **
**  CommonUnits is free software: you can redistribute it and/or modify         **
**  it under the terms of the GNU Lesser General Public License as published by **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  CommonUnits is distributed in the hope that it will be useful,              **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU Lesser General Public License for more details.                         **
**                                                                              **
**  You should have received a copy of the GNU Lesser General Public License    **
**  along with CommonUnits.  If not, see <https://www.gnu.org/licenses/>.       **
**********************************************************************************/
#pragma once

#include "../CommonUnits.h"
#include "../UnitLists.h"

namespace CU
{
inline namespace Power
{
namespace Units
{
using W  = StandardUnit<"W">;
using mW = DeriveUnit<W, "mW", std::milli>;
using uW = DeriveUnit<W, "μW", std::micro>;
using nW = DeriveUnit<W, "nW", std::nano>;
using pW = DeriveUnit<W, "pW", std::pico>;
using fW = DeriveUnit<W, "fW", std::femto>;
using aW = DeriveUnit<W, "aW", std::atto>;
using kW = DeriveUnit<W, "kW", std::kilo>;
using MW = DeriveUnit<W, "MW", std::mega>;
using GW = DeriveUnit<W, "GW", std::giga>;
using TW = DeriveUnit<W, "TW", std::tera>;
using PW = DeriveUnit<W, "PW", std::peta>;
using EW = DeriveUnit<W, "EW", std::exa>;

using PowerList = UnitLists<aW, fW, pW, nW, uW, mW, W, kW, MW, GW, TW, PW, EW>;
} // namespace Units
using Watt      = CommonUnits<double, Units::W>;
using Milliwatt = CommonUnits<double, Units::mW>;
using Microwatt = CommonUnits<double, Units::uW>;
using Nanowatt  = CommonUnits<double, Units::nW>;
using Picowatt  = CommonUnits<double, Units::pW>;
using Femtowatt = CommonUnits<double, Units::fW>;
using Attowatt  = CommonUnits<double, Units::aW>;
using Kilowatt  = CommonUnits<double, Units::kW>;
using Megawatt  = CommonUnits<double, Units::MW>;
using Gigawatt  = CommonUnits<double, Units::GW>;
using Terawatt  = CommonUnits<double, Units::TW>;
using Petawatt  = CommonUnits<double, Units::PW>;
using Exawatt   = CommonUnits<double, Units::EW>;
namespace Literals
{
constexpr auto operator""_W(long double val) { return Watt(val); }
constexpr auto operator""_mW(long double val) { return Milliwatt(val); }
constexpr auto operator""_uW(long double val) { return Microwatt(val); }
constexpr auto operator""_nW(long double val) { return Nanowatt(val); }
constexpr auto operator""_pW(long double val) { return Picowatt(val); }
constexpr auto operator""_fW(long double val) { return Femtowatt(val); }
constexpr auto operator""_aW(long double val) { return Attowatt(val); }
constexpr auto operator""_kW(long double val) { return Kilowatt(val); }
constexpr auto operator""_MW(long double val) { return Megawatt(val); }
constexpr auto operator""_GW(long double val) { return Gigawatt(val); }
constexpr auto operator""_TW(long double val) { return Terawatt(val); }
constexpr auto operator""_PW(long double val) { return Petawatt(val); }
constexpr auto operator""_EW(long double val) { return Exawatt(val); }

} // namespace Literals

template<typename Unit>
inline auto toUnit(double value, const std::string& dest) -> Unit
{
    return toUnitHelper<Unit, Units::PowerList>(value, dest);
}
} // namespace Power
} // namespace CU
